   #include <functional>
    namespace detail {
    
       // 接收和发送消息类型
    template<typename Sender, typename Transformation, typename SourceMessageType = typename Sender::value_type,
        typename MessageType = decltype(std::declval<Transformation>()(std::declval<SourceMessageType>()))>
    class transform_impl {
        public:
            using value_type = MessageType;

            transform_impl(Sender&& sender, Transformation transformation)
                : m_sender(std::move(sender))
                , m_transformation(transformation)
            {

            }

            template<typename EmitFunction>
            void set_message_handler(EmitFunction emit)
            {
                m_emit = emit;
                m_sender.set_message_handler(
                    [this](SourceMessageType&& message) {
                        process_message(
                            std::move(message)
                        );
                    }
                )
            }

            void process_message(SourceMessageType&& message) const
            {
                m_emit(std::invoke(m_transformation, std::move(message)));
            }

        private:
            Sender m_sender;
            Transformation m_transformation;
            std::function<void(MessageType&&)>m_emit;

       
    };
    template <typename Transformation>
        struct transform_helper {
        Transformation function;
        };
    }//detail的结束